package com.titaniume.java2;

import com.titaniume.java1.Person;
import org.junit.Test;

import java.lang.reflect.Constructor;

/**
 * @program: JavaSenior
 * @description:
 * @author: renfei.huang
 * @create: 2021-10-30 11:23
 */
public class OtherTest {


    @Test
    public void test1(){

        Class clazz = Person.class;
        //getConstructors() :当前运行时类中声明为public的构造器
        Constructor[] constructors = clazz.getConstructors();
        for (Constructor constructor : constructors) {
            System.out.println(constructor);
        }


        System.out.println("-------------------");

        //getDeclaredConstructors():获取当前运行时类中声明的所有构造器
        Constructor[] declaredConstructors = clazz.getDeclaredConstructors();
        for (Constructor declaredConstructor : declaredConstructors) {
            System.out.println(declaredConstructor);
        }
    }

}
